Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom coding key and implement codable functions on our own to reduce binary size #144

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

mxsc
Copy link
Collaborator

@mxsc mxsc commented Apr 16, 2024

See swiftlang/swift#60287 and CreateAPI/CreateAPI#57 for more info. But in short apparently letting Xcode synthesize Codable conformance (more specifically CodingKeys) leads to binary size bloat. A simple solution is to create a custom CodingKey struct and then use strings instead of the enum cases in the decode methods.

Going from:

public init(from decoder: Decoder) throws {
            let container = try decoder.container(keyedBy: CodingKeys.self)
            self.deepLink = try container.decode(URL.self, forKey: .deepLink)

To:

public init(from decoder: Decoder) throws {
            let container = try decoder.container(keyedBy: StringCodingKey)
            self.deepLink = try container.decode(URL.self, forKey: "deepLink")

Fixes iOS-238

@mxsc mxsc self-assigned this Apr 16, 2024
Copy link

github-actions bot commented Apr 16, 2024

Test Results

60 tests   60 ✅  3s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit 07cfa29.

♻️ This comment has been updated with latest results.

@mxsc mxsc requested a review from MadsBogeskov April 16, 2024 11:07
@mxsc mxsc merged commit f358db1 into main Apr 16, 2024
3 checks passed
@mxsc mxsc deleted the ms/use-custom-string-coding-key branch April 16, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants